package com.huilian.iotbox.admin.wap.controller;
import com.huilian.iotbox.admin.wap.service.CustomerServiceInfoService;
import com.huilian.iotbox.data.common.ServerResponse;
import com.huilian.iotbox.data.dto.CustomerServiceInfoDto;
import com.huilian.iotbox.data.vo.UserInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
/**
 * @author 龙 路 飞
 * @CreateDate: 2021-11-09 16:13
 * @Description:
 */
@RestController
@RequestMapping("/api/customerServiceInfo")
public class CustomerServiceInfoController extends UserInfoController {
    @Autowired
    private CustomerServiceInfoService customerServiceInfoService;


    @PostMapping("/findByUserIdList")
    public ServerResponse findByUserIdList(HttpServletRequest request, @RequestBody CustomerServiceInfoDto customerServiceInfoDto) {
        UserInfo userInfo = super.getLoginUserInfo(request);
        customerServiceInfoDto.setUserInfo(userInfo);
        return ServerResponse.createBySuccess(customerServiceInfoService.findByUserIdList(customerServiceInfoDto));
    }

    @PostMapping("/findByUserIdPages")
    public ServerResponse findByUserIdPages(HttpServletRequest request, @RequestBody CustomerServiceInfoDto customerServiceInfoDto) {
        UserInfo userInfo = super.getLoginUserInfo(request);
        customerServiceInfoDto.setUserInfo(userInfo);
        return ServerResponse.createBySuccess(customerServiceInfoService.findByUserIdPages(customerServiceInfoDto));
    }

    @GetMapping("/findByMerchantStoreId")
    public ServerResponse findByMerchantStoreId(HttpServletRequest request, Integer merchantStoreId) {
        CustomerServiceInfoDto customerServiceInfoDto = new CustomerServiceInfoDto();
        customerServiceInfoDto.setMerchantStoreId(merchantStoreId);
        UserInfo userInfo = super.getLoginUserInfo(request);
        customerServiceInfoDto.setUserInfo(userInfo);
        return ServerResponse.createBySuccess(customerServiceInfoService.findByMerchantStoreId(customerServiceInfoDto));
    }

    @PostMapping("/editWeChat")
    public ServerResponse editWeChat(HttpServletRequest request, @RequestBody CustomerServiceInfoDto customerServiceInfoDto) {
        UserInfo userInfo = super.getLoginUserInfo(request);
        customerServiceInfoDto.setUserInfo(userInfo);
        return customerServiceInfoService.editWeChat(customerServiceInfoDto);
    }

    /**
     * 小程序
     *
     * @param request
     * @param customerServiceInfoDto
     * @return
     */
    @PostMapping("/editWeChatByApplet")
    public ServerResponse editWeChatByApplet(HttpServletRequest request, @RequestBody CustomerServiceInfoDto customerServiceInfoDto) {
        UserInfo userInfo = super.getLoginUserInfo(request);
        customerServiceInfoDto.setUserInfo(userInfo);
        return customerServiceInfoService.editWeChatByApplet(customerServiceInfoDto);
    }

    @GetMapping("/deleteServiceWeChatQr")
    public ServerResponse deleteServiceWeChatQr(HttpServletRequest request, String serviceWeChatQr) {
        CustomerServiceInfoDto customerServiceInfoDto = new CustomerServiceInfoDto();
        UserInfo userInfo = super.getLoginUserInfo(request);
        customerServiceInfoDto.setUserInfo(userInfo);
        customerServiceInfoDto.setServiceWeChatQr(serviceWeChatQr);
        return customerServiceInfoService.deleteServiceWeChatQr(customerServiceInfoDto);
    }

    @PostMapping("/editPhone")
    public ServerResponse editPhone(HttpServletRequest request, @RequestBody CustomerServiceInfoDto customerServiceInfoDto) {
        UserInfo userInfo = super.getLoginUserInfo(request);
        customerServiceInfoDto.setUserInfo(userInfo);
        return customerServiceInfoService.editPhone(customerServiceInfoDto);
    }

    @PostMapping("/clearPhone")
    public ServerResponse clearPhone(HttpServletRequest request, @RequestBody CustomerServiceInfoDto customerServiceInfoDto) {
        UserInfo userInfo = super.getLoginUserInfo(request);
        customerServiceInfoDto.setUserInfo(userInfo);
        return customerServiceInfoService.clearPhone(customerServiceInfoDto);
    }

    @PostMapping("/clearWeChat")
    public ServerResponse clearWeChat(HttpServletRequest request, @RequestBody CustomerServiceInfoDto customerServiceInfoDto) {
        UserInfo userInfo = super.getLoginUserInfo(request);
        customerServiceInfoDto.setUserInfo(userInfo);
        return customerServiceInfoService.clearWeChat(customerServiceInfoDto);
    }

}
